User=$1
DNS=$2

Result=$(ssh -i key-pair.pem $User@$DNS 'exit' || echo "SSH login failed.")	
while [ "$Result" != "" ]
do
	Result=$(ssh -i key-pair.pem $User@$DNS 'exit' || echo "SSH login failed.")	
	echo "for $User@$DNS: $Result"
	sleep 1
done
echo "Successfully connected to $User@$DNS"

#ssh -i key-pair.pem $User@$DNS
